#!/usr/bin/env python
# -*- coding: utf-8 -*-

from optparse import OptionParser

import httplib2

def get_resource(collection, verbose=False):
    h = httplib2.Http()
    r, c = h.request('http://localhost:8080/atom/%s' % collection)

    if verbose:
        print r
        print c
        
def parse_command_line():
    parser = OptionParser()
    parser.add_option("-c", "--collection", dest="collection",
                      help="name of the collection to get")
    parser.add_option("-v", "--verbose", action="store_true", default=False,
                      help="if used will display the response sent by the server")

    (options, args) = parser.parse_args()

    return options.collection, options.verbose

if __name__ == '__main__':
    collection, verbose = parse_command_line()
    if collection is None:
        print "ABORTED: You must provide a collection name"
    else:
        get_resource(collection, verbose)
